package com.example.interviewrecorder.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.example.interviewrecorder.model.Record

@Dao
interface RecordDao {
    @Insert
    fun insertRecord(record: Record)

    @Delete
    fun deleteRecord(record: Record)

    @Update
    fun updateRecord(newRecord:Record)

    @Query("select * from Record where userId = :userId")
    fun queryAllRecord(userId: Long):List<Record>

    @Query("SELECT * FROM Record " +
            "WHERE (title LIKE '%' || :keyword || '%' " +
            "OR content LIKE '%' || :keyword || '%' " +
            "OR corporateName LIKE '%' || :keyword || '%') " +
            "AND userId = :userId")
    fun queryRecordByKeywordAndUserId(keyword: String, userId: Long): List<Record>
}